package com.eastcom.dataquality.core.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.eastcom.dataquality.core.module.DBSource;

public class DBSourceDao extends JdbcDaoSupport implements RowMapper<DBSource>{

	
	public List<DBSource> findAll(){
		String sql="select * from qa_dbsource";
		List<DBSource> results=getJdbcTemplate().query(sql, this);
		return results;
	}
	
	public DBSource mapRow(ResultSet rs, int rowNum) throws SQLException {
		DBSource source=new DBSource();
		source.setId(rs.getString("id"));
		source.setDbType(rs.getString("dbType"));
		source.setHost(rs.getString("host"));
		source.setPort(rs.getInt("port"));
		source.setUserName(rs.getString("username"));
		source.setPassWord(rs.getString("password"));
		return source;
	}
	
}
